package org.erp.product.infrastructure.enums;

import lombok.Getter;

/**
 * @author libin
 * @version 1.0
 * @description:
 * @date 2025/11/17 9:34
 **/
@Getter
public enum InspectionStatusEnum {
    WAITING_INSPECTION(0, "待质检"),
    QUALIFIED(1, "待上架"),
    ON_SHELF(2, "已上架"),
    OFF_SHELF(3, "已下架"),
    TRANSFERRING(4, "调拨中"),
    CONNECTED(5, "已接驳"),
    WAITING_RECYCLE(6, "待返库"),
    RECYCLED(7, "已返库");

    private final Integer code;
    private final String message;

    InspectionStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Integer getCodeByMessage(String message) {
        for (InspectionStatusEnum item : InspectionStatusEnum.values()) {
            if (item.getMessage().equals(message)) {
                return item.getCode();
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        for (InspectionStatusEnum item : InspectionStatusEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getMessage();
            }
        }
        return null;
    }

    public static InspectionStatusEnum getByCode(Integer code) {
        for (InspectionStatusEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static InspectionStatusEnum getByMessage(String message) {
        for (InspectionStatusEnum value : values()) {
            if (value.getMessage().equals(message)) {
                return value;
            }
        }
        return null;
    }
}
